<?php
require_once("../includes/config.inc.php");
include("./fckeditor/fckeditor.php") ;

validate_admin();
$pageId = $_REQUEST['pageId'];
if($_POST)
{
	@extract($_POST);
	//$pageContent = $pageContent;
	if(isFieldDuplicate($tableName='tbl_pages',$fieldName='pageName',$filedValue=$pageName,$autoIdName='pageId',$autoIdValue=$pageId,$isNullAllowed=false)) 
			{
				$_SESSION['sessMsg'] ="Sorry, the pagename'".$pageName."' is not available. Try another." ;
			 }
		else 
			{	 
					if($pageId)
					{
						$sqlEdit = " update tbl_pages set 
									
									 pageName = '$pageName',
									 pageContent = '$pageContent'
									where pageId = '$pageId'
									";	
								executeQuery($sqlEdit);
								$_SESSION['sessMsg'] = " Page Detail Edited Successfully. ";
								header("location:adminPageManager.php");
								exit();
					}
	
				else
	         		{
						$sqlqr=" insert into tbl_pages(pageName,pageContent) values('$pageName','$pageContent')";
						executeQuery($sqlqr);
						$_SESSION['sessMsg'] = " Page added  Successfully. ";
						header("location:adminPageManager.php");
						exit();
					}
				}		
	}

if($pageId)
{
	$sqlPD = " select * from tbl_pages where pageId = '$pageId' ";
	$resPD = executeQuery($sqlPD);
	if($rowPD = mysql_fetch_array($resPD))
	{
		@extract($rowPD);
	}
}
?>